package serializer

import (
	"go-mall/model"
)

type Notification struct {
	Id      uint   `json:"id"`
	Title   string `json:"title"`
	Content string `json:"content"`
	Created int64  `json:"created"`
}

func BuildNotification(item *model.Notification) Notification {
	return Notification{
		Id:      item.ID,
		Title:   item.Title,
		Content: item.Content,
		Created: item.CreatedAt.Unix(),
	}
}

func BuildListNotification(items []*model.Notification) (notifications []Notification) {
	for _, item := range items {
		category := BuildNotification(item)
		notifications = append(notifications, category)
	}
	return notifications
}
